Copyright 2003-2007 Chris Mallett (support@autohotkey.com)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
#ifndef clipboard_h
#define clipboard_h
#include "stdafx.h" // pre-compiled headers
#include "defines.h"
#define CANT_OPEN_CLIPBOARD_READ "Can't open clipboard for reading."
#define CANT_OPEN_CLIPBOARD_WRITE "Can't open clipboard for writing."
class Clipboard
{
public:
HGLOBAL mClipMemNow, mClipMemNew;
char *mClipMemNowLocked, *mClipMemNewLocked;
size_t mLength; // Last-known length of the clipboard contents (for internal use only because it's valid only during certain specific times).
UINT mCapacity; // Capacity of mClipMemNewLocked.
BOOL mIsOpen; // Whether the clipboard is physically open due to action by this class. BOOL vs. bool improves some benchmarks slightly due to this item being frequently checked.
// It seems best to default to many attempts, because a failure
// to open the clipboard may result in the early termination
// of a large script due to the fear that it's generally
// unsafe to continue in such cases. Update: Increased default
// number of attempts from 20 to 40 because Jason (Payam) reported
// that he was getting an error on rare occasions (but not reproducible).
ResultType Open();
HANDLE GetClipboardDataTimeout(UINT uFormat);
// Below: Whether the clipboard is ready to be written to. Note that the clipboard is not
// usually physically open even when this is true, unless the caller specifically opened